home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1988 / 04 / crum.asm next >
Assembly Source File  |  1988-05-09  |  1KB  |  44 lines

  1. ----------------------------------------------------------
  2.         .DATA
  3.  
  4. ;-----  Command  character list
  5.  
  6. chars   DB      "0123"
  7. 1chars  EQU     $-chars           ; length of command character list
  8.  
  9. ;-----  Jump (case) table of addresses
  10.  
  11. table   DW      case0,case1,case2,case3,endcase
  12.  
  13. ;-----  Various strings
  14.  
  15. etc...
  16.  
  17. -----------------------------------------------------------------
  18.         .CODE
  19. start:
  20.         mov     ax,@data          ; initialize DS & ES
  21.         mov     ds,ax
  22.         mov     es,ax
  23.  
  24. etc...
  25.  
  26. ------------------------------------------------------------------
  27.  
  28. ;-----  Prepare DI equal to the case statement number times2,
  29.         indexing the 2-byte addresses in the jump table.
  30.  
  31.         mov     dx,OFFSET errmsg  ; Prepare for possible error
  32.         mov     di,OFFSET chars   ; Point to command character table
  33.         mov     cx,1chars+1       ; Load length of character table
  34.         cld                       ; Scan forward
  35.         repne   scasb             ; Find the command character 
  36.         sub     di,OFFSET chars+1 ; Point to procedure
  37.         shl     di,1              ; Convert to word address
  38.         jmp     table[di]         ; Jump to case 0,1,2,3, or endcase
  39.  
  40. etc...
  41.  
  42. ---------------------------------------------------------------------  
  43.  
  44. End of listings.